<#assign menu="goods">
<#assign submenu="update_goods">
<#include "/system/head.ftl">
<!--main content start-->
<style type="text/css">

</style>
<section id="main-content">
	<section class="wrapper">
		<!-- page start-->
		<form id="update_goods_form" class="form-horizontal" action="${basePath}/admin/goods/update.json"  autocomplete="off"  method="post"
			enctype="multipart/form-data">
		<div class="row">
			<div class="col-lg-12">
				<section class="panel">
					<header class="panel-heading"> 
						修改产品
					</header>
					<div class="panel-body">
					<input type="hidden" name="goodsItemEntity.goodsId" value="${goodsItemEntity.goodsId?c}" id="goodsId" />
						<div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品名称</label>
                          <div class="col-sm-10">
                              <input type="text" style="font-size:15px;width: 300px;" class="form-control" name="goodsItemEntity.title"
                              	placeholder="产品名称" id="title" value="${goodsItemEntity.title}" >
                              </input>
                          </div>
                        </div>
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">所属栏目</label>
                          <div class="col-sm-10">
                              <select class="form-control" id="classId" name="goodsItemEntity.classId" style="font-size:15px;width: 300px;">
			                   		<#list classesList as classes>
			                   			<option style="background-color:#DFF0D8;font-weight:bold;" value="${classes.id}" selected>${classes.name}</option>
			                   		</#list>						
	                            </select>			
                          </div>
                        </div>  
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">摘要</label>
                          <div class="col-sm-10">
                              <input type="text" style="font-size:15px;" class="form-control" id="description" name="goodsItemEntity.description"
                              	placeholder="摘要" id="summary" value="${goodsItemEntity.description}" >
                              </input>
                          </div>
                        </div>                                              
						<div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label">产品内容</label>
                              <div class="col-sm-10">
                                  <script id="content" name="content" type="text/plain"
										style="width: 100%; height: 260px;">${goodsItemEntity.content!}</script>
								  <script type="text/javascript">
									var contentEditor;
									$(function() {
										contentEditor = UE.getEditor('content');
									});
								  </script>
                              </div>
                        </div>
                     
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品状态</label>
                          <div class="col-sm-10" style="margin-bottom:10px;">
                          	<input name="goodsItemEntity.status" id="status" value="1" type="radio" <#if (goodsItemEntity.status==1)>checked</#if>> 显示
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="status" value="0" type="radio" <#if (goodsItemEntity.status==0)>checked</#if>> 隐藏
                          </div>
                        </div>
                        
                         <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品来源</label>
                          <div class="col-sm-10" style="margin-bottom:10px;">
                          	<input name="goodsItemEntity.productFrom" id="productFrom" value="0" type="radio" checked> 淘宝
							<input name="goodsItemEntity.productFrom" value="1" type="radio"> 京东
							<input name="goodsItemEntity.productFrom" value="2" type="radio"> 自有
                          </div>
                        </div>
                        
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品价格</label>
                          <div class="col-sm-10">
                              <input type="text" style="font-size:15px;width: 300px;display: inline-block;" class="form-control" name="goodsItemEntity.productPrice"
                              	placeholder="产品价格" id="productPrice" value="<#if goodsItemEntity.productPrice??>${goodsItemEntity.productPrice}<#else>0</#if>" >
                              </input>
                          </div>
                        </div>
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品原价</label>
                          <div class="col-sm-10">
                              <input type="text" style="font-size:15px;width: 300px;display: inline-block;" class="form-control" name="goodsItemEntity.productOriginalPrice"
                              	placeholder="产品原价" id="productOriginalPrice" value="<#if goodsItemEntity.productOriginalPrice??>${goodsItemEntity.productOriginalPrice}<#else>0</#if>" >
                              </input>
                          </div>
                        </div>
                        <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">产品返现比例</label>
                          <div class="col-lg-10">
                              <input type="text" style="font-size:15px;width: 300px;display: inline-block;" class="form-control" name="goodsItemEntity.productCommission"
                              	placeholder="产品返现比例" id="productCommission" value="<#if goodsItemEntity.productCommission??>${goodsItemEntity.productCommission}<#else>0</#if>" />%
                          </div>
                        </div>
                        
                        <div class="form-group">
	                          <label class="col-sm-2 col-sm-2 control-label">产品图片</label>
	                          <div class="col-sm-6">
	                              <input type="text" readOnly="false" class="form-control" name="goodsItemEntity.productPicUrl"
	                              	placeholder="产品图片" id="productPicUrl" value="<#if goodsItemEntity.productPicUrl??>${goodsItemEntity.productPicUrl}</#if>">
	                              	<label class="col-lg-offset-10 ">
	                                  	<button id="file_upload"  class="btn btn-shadow btn-info" type="button"><i class="icon-cloud-upload"></i> 上传图片</button>
	                             	</label>
	                          </div>
	                      </div>    
	                      
                        <div class="form-group">
                      	  <div class="col-lg-offset-2 col-lg-10">
                          <button class="btn btn-shadow btn-primary" type="submit">修改</button>
                          </div>
                      </div>
					</div>
				</section>
			</div>
		</div>
		</form>
		<!-- page end-->
	</section>
</section>
<!--main content end-->
<script type="text/javascript" charset="utf-8" src="${basePath}/system/assets/uploadify/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="${basePath}/system/assets/uploadify/jquery.uploadify.min.js"></script>

<script type="text/javascript">
$(function(){
	$('#update_goods_form').ajaxForm({
		dataType : 'json',
		success : function(data) {
			if (data.result) {
				bootbox.alert("保存成功，将刷新页面", function() {
					window.location.reload();
					
				});
			}else{
				showErrors($('#update_goods_form'),data.errors);
			}
		},
		error:function(data,textstatus){
	        bootbox.alert({  
	            buttons: {  
	               ok: {  
	                    label: '关闭'
	               }  
	            },
	            message: data.responseText,
	            title: '<@spring.message "system.errorTip"/>',  
	        });
	     } 
	});
	$('#file_upload').uploadify({
		'buttonText'  		: 	'请选择文件',
        'swf'         		: 	'${basePath}/system/assets/uploadify/uploadify.swf',
        'uploader'    		: 	'${basePath}/admin/attachment/upload.json',
        'formData'  		: 	{"fileType":"picture"},
        'fileObjName'		: 	'file',
        'fileTypeExts' 		: 	'*.*',
        'method'			:	'post',
        'onUploadSuccess' 	: 	function(file, data, response) {
        	var jsonData=$.parseJSON(data);
        	if(jsonData.state=="SUCCESS"){
	        	$("#productPicUrl").val(jsonData.url);
        	}else
        	{
        		 bootbox.alert({  
		            buttons: {  
		               ok: {  
		                    label: '关闭'
		               }  
		            },
		            message: jsonData.state,
		            title: '<@spring.message "system.errorTip"/>',  
		        });
        	}
        }
	});
});
</script>
<#include "/system/foot.ftl">
